﻿using Xejen.Ipc.Framework.Flows;
using System;
using System.Collections.Generic;
using System.Text;

namespace Xejen.Ipc.Framework.Steps
{
    /// <inheritdoc cref="IStepProvider{TData}"/>
    internal class StepProvider<TData> : IStepProvider<TData>
        where TData : new()
    {
        /// <inheritdoc cref="StepProvider{TData}"/>
        public StepProvider() { }

        /// <inheritdoc/>
        public IStep<TData> New<TStepBody>(string stepName = null) where TStepBody : IStepBody<TData>, new()
        {
            StepBuilder<TData, TStepBody> builder = new StepBuilder<TData, TStepBody>(stepName);
            return builder.Build();
        }
    }

    /// <summary>
    /// 用于创建步骤<see cref="IStep{TData}"/>的驱动器对象
    /// </summary>
    /// <typeparam name="TData"><inheritdoc cref="IFlow{TData}" path="/typeparam[@name='TData']"/></typeparam>
    /// <creator>marc</creator>
    public interface IStepProvider<TData>
        where TData : new()
    {
        /// <summary>
        /// 创建一个新的步骤<see cref="IStep{TData}"/>对象
        /// </summary>
        /// <typeparam name="TStepBody"><inheritdoc cref="IStepBody{TData}" path="/summary"/></typeparam>
        /// <param name="stepName"><inheritdoc cref="IStep{TData}.Name" path="/summary"/></param>
        /// <returns></returns>
        IStep<TData> New<TStepBody>(string stepName = null) where TStepBody : IStepBody<TData>, new();
    }
}
